///
/// This method validates the page whenever the text in the ${Validate Field} TextBox changes.
///
private void ${Validate Field Control}_TextChanged(object sender, System.EventArgs e)
{
try
{
Validate();
}
catch (Exception ex)
{
// Exception thrown by the Validate() sub is caught here.
// Report the error message to the user.
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPTKEY", "${Validate Field Control} cannot be empty ");
}
}
///
/// Override the Validate() method. Add your validation logic here.
/// If the value of ${Validate Field Control} is not valid
/// then throw an exception. The exception is caught in the ${Validate Field Control}_TextChanged
/// event handler and it calls RegisterJScriptAlert to report the error message to the user.
/// Throwing an exception in Validate() method ensures that the record will not be saved. If you do not throw an exception
/// record will be saved. You can also validate other fields in the Validate() method.
/// In this customization ${Validate Field Control}_TextChanged will report an error message to the user
/// if an exception is thrown by the Validate method. After the ${Validate Field Control}_TextChanged event
/// when the user clicks on the save button, the exception thrown by the Validate() method will get caught
/// by the SaveButton_Click handler, which will call the RegisterJScriptAlert to report the error message to the user.
///
public override void Validate()
{
// Call base Validate()
base.Validate();
// Add validation logic here
if (this.${Validate Field Control}.Text == "")
{
throw new Exception();
}
}
|